#!/usr/bin/env python3
import time
import sys

# 先 withdraw、再 announce 相同前缀
prefix = "2222:77::/64"
# 等待ExaBGP与R2建立连接
time.sleep(30)
sys.stdout.write("announce route {} next-hop 2222:33::1 med 100\n".format(prefix))
sys.stdout.flush()
time.sleep(8)

sys.stdout.write("withdraw route {} next-hop 2222:33::1\n".format(prefix))
sys.stdout.flush()
time.sleep(8)

sys.stdout.write("announce route {} next-hop 2222:33::1 med 100\n".format(prefix))
sys.stdout.flush()
time.sleep(8)

sys.stdout.write("announce route {} next-hop 2002::35 med 200\n".format(prefix))
sys.stdout.flush()

# 防止脚本退出被 ExaBGP 杀死
while True:
    time.sleep(60)
